.TH std::ranges::filter_view::iterator 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::filter_view::iterator \- std::ranges::filter_view::iterator

.SH Synopsis
   class /*iterator*/;  \fI(since C++20)\fP
                        (exposition only*)

   The return type of filter_view::begin.

   This is a bidirectional_iterator if V models bidirectional_range, a forward_iterator
   if V models forward_range, and input_iterator otherwise.

   Modification of the element denoted by this iterator is permitted, but results in
   undefined behavior if the resulting value does not satisfy the filter's predicate.

.SH Member types

   Member type       Definition
                       * std::bidirectional_iterator_tag, if V models
   iterator_concept      bidirectional_range,
                       * std::forward_iterator_tag, if V models forward_iterator,
                       * std::input_iterator_tag otherwise.
                     Defined if and only if V models forward_range. Let C be the type
                     std::iterator_traits<ranges::iterator_t<V>>::iterator_category.

   iterator_category   * std::bidirectional_iterator_tag, if C models
                         std::derived_from<std::bidirectional_iterator_tag>,
                       * std::forward_iterator_tag, if C models
                         std::derived_from<std::forward_iterator_tag>,
                       * C otherwise.
   value_type        ranges::range_value_t<V>
   difference_type   ranges::range_difference_t<V>

   Data members

   Member name        Definition
                      An iterator of type ranges::iterator_t<V> into the underlying
   current_ (private) view.
                      (exposition-only member object*)
                      A pointer of type ranges::filter_view<V, Pred>* to the parent
   parent_ (private)  filter_view object.
                      (exposition-only member object*)

.SH Member functions

   constructor     constructs an iterator
   (C++20)         \fI(public member function)\fP
   base            returns the underlying iterator
   (C++20)         \fI(public member function)\fP
   operator*       forwards to the underlying iterator
   operator->      \fI(public member function)\fP
   (C++20)
   operator++      advances the iterator
   operator++(int) \fI(public member function)\fP
   (C++20)
   operator--      decrements the iterator
   operator--(int) \fI(public member function)\fP
   (C++20)

std::ranges::filter_view::iterator::iterator

   /*iterator*/()                                                          (since
     requires std::default_initializable<ranges::iterator_t<V>> =      \fB(1)\fP C++20)
   default;
   constexpr /*iterator*/( filter_view& parent,                        \fB(2)\fP (since
                           ranges::iterator_t<V> current );                C++20)

   1) Initializes current_ and parent_ with their default member initializers, which
   are = ranges::iterator_t<V>() and = nullptr respectively.
   2) Initializes current_ with std::move(current) and parent_ with
   std::addressof(parent).

std::ranges::filter_view::iterator::base

   constexpr const ranges::iterator_t<V>& base() const & noexcept; \fB(1)\fP \fI(since C++20)\fP
   constexpr ranges::iterator_t<V> base() &&;                      \fB(2)\fP \fI(since C++20)\fP

   1) Equivalent to return current_;.
   2) Equivalent to return std::move(current_);.

std::ranges::filter_view::iterator::operator*,->

   constexpr ranges::range_reference_t<V> operator*() const; \fB(1)\fP \fI(since C++20)\fP
   constexpr ranges::iterator_t<V> operator->() const

     requires /*has-arrow*/<ranges::iterator_t<V>> &&        \fB(2)\fP \fI(since C++20)\fP

              std::copyable<ranges::iterator_t<V>>;

   1) Equivalent to return *current_;.
   2) Equivalent to return current_;.
   For a type I, /*has-arrow*/<I> is modeled or satisfied, if and only if I models or
   satisfies input_iterator respectively, and either I is a pointer type or requires(I
   i){ i.operator->();} is true.

std::ranges::filter_view::iterator::operator++

   constexpr /*iterator*/& operator++();    \fB(1)\fP \fI(since C++20)\fP
   constexpr void operator++( int );        \fB(2)\fP \fI(since C++20)\fP
   constexpr /*iterator*/ operator++( int ) \fB(3)\fP \fI(since C++20)\fP
     requires ranges::forward_range<V>;

   1) Equivalent to
   current_ = ranges::find_if(std::move(++current_), ranges::end(parent_->base_),

                              std::ref(*parent_->pred_));

   return *this;.
   2) Equivalent to ++*this;.
   3) Equivalent to auto tmp = *this; ++*this; return tmp;.

std::ranges::filter_view::iterator::operator--

   constexpr /*iterator*/& operator--()       \fB(1)\fP \fI(since C++20)\fP
     requires ranges::bidirectional_range<V>;
   constexpr /*iterator*/ operator--( int )   \fB(2)\fP \fI(since C++20)\fP
     requires ranges::bidirectional_range<V>;

   1) Equivalent to
   do

       --current_;
   while (!std::invoke(*parent_->pred_, *current_));

   return *this;.
   2) Equivalent to auto tmp = *this; --*this; return tmp;.

.SH Non-member functions

   operator== compares the underlying iterators
   (C++20)    \fI(function)\fP
   iter_move  casts the result of dereferencing the underlying iterator to its
   (C++20)    associated rvalue reference type
              \fI(function)\fP
   iter_swap  swaps the objects pointed to by two underlying iterators
   (C++20)    \fI(function)\fP

operator==(std::ranges::filter_view::iterator)

   friend constexpr bool operator==( const /*iterator*/& x, const
   /*iterator*/& y )                                                      \fI(since C++20)\fP
     requires std::equality_comparable<ranges::iterator_t<V>>;

   Equivalent to return x.current_ == y.current_;.

   The != operator is synthesized from operator==.

   This function is not visible to ordinary unqualified or qualified lookup, and can
   only be found by argument-dependent lookup when std::ranges::filter_view::iterator
   is an associated class of the arguments.

iter_move(std::ranges::filter_view::iterator)

   friend constexpr ranges::range_rvalue_reference_t<V>

     iter_move( const /*iterator*/& i )                    \fI(since C++20)\fP

       noexcept(noexcept(ranges::iter_move(i.current_)));

   Equivalent to return ranges::iter_move(i.current_);.

   This function is not visible to ordinary unqualified or qualified lookup, and can
   only be found by argument-dependent lookup when std::ranges::filter_view::iterator
   is an associated class of the arguments.

iter_swap(std::ranges::filter_view::iterator)

   friend constexpr void iter_swap( const /*iterator*/& x, const
   /*iterator*/& y )
                                                                          \fI(since C++20)\fP
     noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))

       requires std::indirectly_swappable<ranges::iterator_t<V>>;

   Equivalent to ranges::iter_swap(x.current_, y.current_).

   This function is not visible to ordinary unqualified or qualified lookup, and can
   only be found by argument-dependent lookup when std::ranges::filter_view::iterator
   is an associated class of the arguments.

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to         Behavior as published              Correct behavior
   P2259R1  C++20      member type iterator_category was     defined only if V is a
                       always defined                        forward_range
   LWG 3533 C++20      the const& overload of base copied    returns a reference to it
                       the underlying iterator
   LWG 3593 C++20      the const& overload of base might not made noexcept
                       be noexcept
